package com.hp.service.strategy;

import com.hp.model.strategy.StrategyRequest;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author hp
 */
@Component
public class ContextFacade {

    public static final Map<String, Strategy> SERVICE_HASH_MAP = new ConcurrentHashMap<>();


    public int doOperation(StrategyRequest strategyRequest) {
        int i = executeStrategy(strategyRequest.getExecutor()).doOperation(strategyRequest.getParam1(), strategyRequest.getParam2());
        return i;
    }

    private Strategy executeStrategy(String strategy) {
        return SERVICE_HASH_MAP.get(strategy);
    }
}